import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { Product } from './product.entity';

@Entity()
export class ProductOption {
  @PrimaryGeneratedColumn('uuid')
  optionId: string;

  @Column()
  optionName: string;

  @Column('decimal')
  price: number;

  @ManyToOne(() => Product, (product) => product.ProductOptionList, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  @JoinColumn({ name: 'optionId' }) // 指定关联表中的外键字段
  product: Product;
}
